package cn.q3c.parse.stock2.impl;

import java.io.File;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import cn.q3c.parse.base.BaseParse;
import cn.q3c.parse.stock2.object.StockInfo;
import cn.q3c.parse.stock2.commons.StockUtils;

/**
 * 股票DBF数据解析
 * 
 * @author wangxinning
 * 
 */
public class Stock2DBFParseImpl implements BaseParse {

	private static final Logger logger = Logger
			.getLogger(Stock2DBFParseImpl.class);

	public Object parse(String url, File file) {

		List<StockInfo> stockList = null;
		
		try
		{
			if( StringUtils.contains(url, "show2003") )
			{
				stockList = StockUtils.toStockInfoList(file, StockInfo.SC_SHANGHAI);
			}
			else if( StringUtils.contains(url, "sjshq") )
			{
				stockList = StockUtils.toStockInfoList(file, StockInfo.SC_SHENZHEN);
			}
		}
		catch( Exception e )
		{
			logger.error("DBF文件解析异常", e);
		}

		return stockList;
	}
}